<!--  -->
<template>
  <div class="swiper">
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item
        v-for="(item, index) in swiperList"
        :key="index"
        @click="$router.push('/liveSale')"
      >
        <img :src="item.image_src" alt="" />
      </van-swipe-item>
    </van-swipe>
  </div>
</template>

<script>
import Vue from "vue";
import { Swipe, SwipeItem } from "vant";
import { apiGetSwiper } from "../../api/home";
Vue.use(Swipe);
Vue.use(SwipeItem);

export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      swiperList: [],
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {},
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {
    apiGetSwiper().then((res) => {
      this.swiperList = res.message;
    });
  },
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
};
</script>
<style lang="scss" scoped>
.my-swipe {
  overflow: hidden;
  width: 95%;
  height: 9.375rem;
  margin: 0.5rem auto;
  border-radius: 0.3125rem;
}
.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 1.25rem;
  text-align: center;
  background-color: #39a9ed;
}
.van-swipe-item img {
  width: 100%;
  height: 9.375rem;
  object-fit: cover;
}
</style>
